package java7_29;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class zuoye6 {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new FileReader("PollingCallName"));
		ArrayList<String> list=new ArrayList<>();
		ArrayList<String> list1=new ArrayList<>();
		String s;
		while((s=br.readLine())!=null){
			list.add(s);
		}
		br.close();
		long count = list.stream().filter(t->t.contains("x")).count();
		if(count==list.size()){
			for(int i=0;i<list.size();i++){
				String s1=list.get(i);
				list1.add(s1.split(":")[0]);
			}
			list=list1;
		}
		while(true){
			Collections.shuffle(list);
			if(!list.get(0).contains("x")){
				break;
			}
		}
		System.out.println(list.get(0));
		list.set(0, list.get(0)+":x");
		BufferedWriter bw=new BufferedWriter(new FileWriter("PollingCallName"));
		for(String s1:list){
			bw.write(s1+"\n");
		}bw.close();
	}
}
